#pragma once

#include <map>

#include <IOmenEvent.h>
#include <IOmenEventHandler.h>

namespace Omen 
{

class TypeInfo
{
public:
	explicit TypeInfo(const type_info& info) : _typeInfo(info) {};

	bool operator < (const TypeInfo& rhs) const
	{
		return _typeInfo.before(rhs._typeInfo) != 0;
	}

private:
	const type_info& _typeInfo;
};

class HandlerFunctionBase
{
public:
	virtual ~HandlerFunctionBase() {};
	void exec(const Omen::Event* event) {call(event);}

private:
	virtual void call(const Omen::Event*) = 0;
};


template <class T, class EventT>
class MemberFunctionHandler : public HandlerFunctionBase
{
public:
	typedef void (T::*MemberFunc)(EventT*);
	MemberFunctionHandler(T* instance, MemberFunc memFn) : _instance(instance), _function(memFn) {};

	void call(const Omen::Event* event)
	{
		(_instance->*_function)(static_cast<EventT*>(event));
	}

private:
	T* _instance;
	MemberFunc _function;
};

} // namespace Omen

/// EOF